<?php
if ( IPB_THIS_SCRIPT != 'admin' )
{
	print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'init.php'.";
	exit();
}

class ad_receipts
{
	var $ipsclass;
	var $LIMIT = 50;
	
	function auto_run()
	{
		$this->ipsclass->DB->load_cache_file(ROOT_PATH.'sources/market/'.$this->ipsclass->vars['sql_driver'].'_market_queries.php','sql_market_queries');
		
		$this->ipsclass->input['st'] = intval($this->ipsclass->input['st']);
		
		$this->ipsclass->admin->page_title  = "Welcome to logs page for the Bank";
		$this->ipsclass->admin->page_detail = "Welcome to logs page for the Bank";
		
		$this->ipsclass->DB->build_query_from_cache('acp_get_receipts_count',array(),'sql_market_queries');
		$this->ipsclass->DB->exec_query();
		$total_count = $this->ipsclass->DB->get_num_rows();
		
		$page = $this->ipsclass->adskin->build_pagelinks(	array(	'TOTAL_POSS'   => $total_count,
																	'PER_PAGE'     => $this->LIMIT,
																	'USE_ST'       => 'st',
																	'CUR_ST_VAL'   => $this->ipsclass->input['st'],
																	'L_SINGLE'     => "Single Page",
																	'BASE_URL'     => $this->ipsclass->base_url."&amp;".$this->ipsclass->form_code."&amp;ACT=logs"
															)	);

		$this->ipsclass->html .= $this->ipsclass->adskin->add_standalone_row($page,"left");
		
		$this->ipsclass->html .= "<br />";
		
		$this->ipsclass->adskin->td_header[] = array( "IP Address"  , "" );
		$this->ipsclass->adskin->td_header[] = array( "Member"      , "" );
		$this->ipsclass->adskin->td_header[] = array( "Time"        , "" );
		$this->ipsclass->adskin->td_header[] = array( "Method"      , "" );
		$this->ipsclass->adskin->td_header[] = array( "Items"       , "" );
		$this->ipsclass->adskin->td_header[] = array( "Total"       , "" );
		
		$this->ipsclass->html .= $this->ipsclass->adskin->start_table("List of receipts");
		
		$tranlate = array('buy'=>"Buying",'resell'=>"Resell");
		$field = array('buy'=>"total_price",'resell'=>"total_resell");
		
		$this->ipsclass->DB->build_query_from_cache('acp_get_receipts',array('st'=>$this->ipsclass->input['st'],'limit'=>$this->LIMIT),'sql_market_queries');
		$this->ipsclass->DB->exec_query();
		while($receipt = $this->ipsclass->DB->fetch_row())
		{
			$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(  $receipt['ip_address'],
																				  $receipt['members_display_name'],
																				  $this->ipsclass->get_date($receipt['time_bought'],'LONG'),
																				  $tranlate[$receipt['method']],
																				  $this->ipsclass->do_number_format($receipt['total_quanity']),
																				  $this->ipsclass->do_number_format($receipt[$field[$receipt['method']]]),
																		 )      );
		}
		
		$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
		
		$this->ipsclass->html .= $this->ipsclass->adskin->add_standalone_row($page,"left");
		
		$this->ipsclass->admin->output();
	}
	
}
?>